package com.FH.applyFrom.work_week_plan_detail;

import com.FH.util.ResultDTO;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by Administrator on 2017/11/22 0022.
 */
@Path("/workWeekPlanDetail")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class WorkWeekPlanDetailResource {

    @EJB
    WorkWeekPlanDetailDAO workWeekPlanDetailDAO;

    @GET
    @Path("/{search}&{page}&{size}")
    public ResultDTO getWorkWeekPlanDetailInfo(@PathParam("search")String search, @PathParam("page")String page, @PathParam("size")String size){
        //添加分页查询
        if(page==null||"".equals(page)){
            page = "1";//从第一页查起
        }
        if(size==null||"".equals(size)){
            size = "10";//默认每页10行
        }
        return workWeekPlanDetailDAO.getWorkWeekPlanDetailInfo(search,page,size);
    }

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO addWorkWeekPlanDetailInfo(WorkWeekPlanDetailPullDTO workWeekPlanDetailPullDTO){
        return workWeekPlanDetailDAO.addWorkWeekPlanDetailInfo(workWeekPlanDetailPullDTO);
    }

    @GET
    @Path("/{search}")
    public ResultDTO getWorkWeekPlanDetial(@PathParam("search") String search){
        return workWeekPlanDetailDAO.getWorkWeekPlanDetail(search);
    }

    @GET
    @Path("/download/{search}")
    public  ResultDTO exportWorkWeekPlanDetail(@PathParam("search") String search){
        return workWeekPlanDetailDAO.exportWorkWeekPlanDetail(search);
    }

    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO updateWorkWeekPlanDetailInfo(WorkWeekPlanDetailPullDTO workWeekPlanDetailPullDTO){
        return workWeekPlanDetailDAO.updateWorkWeekPlanDetailInfo(workWeekPlanDetailPullDTO);
    }

    @PUT
    @Path("/delete")
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO deleteWorkWeekPlanDetailInfo(WorkWeekPlanDetailPullDTO workWeekPlanDetailPullDTO){
        return workWeekPlanDetailDAO.deleteWorkWeekPlanDetailInfo(workWeekPlanDetailPullDTO);
    }
}
